package com.joysuch.wwyt.bp.controller;


import com.joysuch.wwyt.bp.bean.inspect.BPInspectPointTypeBean;
import com.joysuch.wwyt.bp.entity.inspect.BPInspectItemType;
import com.joysuch.wwyt.bp.entity.inspect.BPInspectPointType;
import com.joysuch.wwyt.bp.service.BPInspectItemService;
import com.joysuch.wwyt.bp.service.BPInspectPointTypeService;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/bp/inspect-point-type")
@Api(tags = "巡检点-检查点类型管理")
@CrossOrigin
public class BPInspectPointTypeController {

    @Autowired
    private BPInspectPointTypeService inspectPointTypeService;

    @Autowired
    private BPInspectItemService inspectItemService;

    @GetMapping("/list")
    @ApiOperation(value = "01 巡检点类型列表", response = BPInspectItemType.class)
    public ResultBean list(Pageable pageable) {
        return inspectPointTypeService.list(pageable);
    }
    
    @GetMapping("/simpleList")
    @ApiOperation("巡检点类型下拉列表")
    public ResultBean simpleListPointType(){
        return ResultBean.success(inspectPointTypeService.simpleList());
    }

    @PostMapping("/save")
    @RequiresPermissions("bp:inspect-point-type:save")
    @ApiOperation(value = "02 保存巡检点类型", response = BPInspectPointTypeBean.class)
    public ResultBean save(@RequestBody BPInspectPointTypeBean bean) {
        return inspectPointTypeService.save(bean);

    }


    @GetMapping("/getById/{id}")
    @ApiOperation(value = "03 根据巡检点类型ID获取详情", response = BPInspectItemType.class)
    @ApiImplicitParam(name = "id", value = "巡检点类型ID", paramType = "path", required = true)
    public ResultBean getById(@PathVariable Long id) {
        BPInspectPointType inspectPontType = inspectPointTypeService.getById(id);
        return ResultBean.success(inspectPontType);

    }

    @GetMapping("/delete/{id}")
    @RequiresPermissions("bp:inspect-point-type:delete")
    @ApiOperation(value = "04 根据巡检点类型ID删除")
    @ApiImplicitParam(name = "id", value = "巡检项类型ID", paramType = "path", required = true)
    public ResultBean delete(@PathVariable Long id) {

        return inspectPointTypeService.deleteById(id);

    }

}
